Skip to content

feat(auth): 接入阿里云 OAuth 登录与预发控制面隔离 (prepare 2.16.0) - #354

Open
lishengzxc wants to merge 16 commits into
mainfrom
feat/aliyun-oauth-login
Open

lishengzxc wants to merge 16 commits into
mainfrom
feat/aliyun-oauth-login

Conversation

@lishengzxc

@lishengzxc lishengzxc commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • 新增 bl auth --login aliyun:使用 PKCE 和本机回调完成授权,置换 STS,并复用同一会话为 OpenAPI 和 Console 提供凭据与自动续期。会话保存在权限受限、原子写入的本地文件中。
  • 新增 BAILIAN_PRE 国内控制面开关,隔离预发 Profile、凭据和路由;未验证的预发路由不回退到线上。DashScope 推理、MCP 管理和云端 Skill 保留原路由。
  • 收紧并发登录、退出及续期的会话一致性;Console 重试不切换 OAuth 身份,旧格式锁不自动删除,Ctrl+C 可取消在途换票。

Test plan

  • vp check 与工作区各发布包构建通过。
  • 基于分支最新提交,11 套离线回归共 282 项通过,覆盖鉴权、会话隔离、并发重试和锁恢复。
  • 本地 CLI 冒烟:换票中断返回 130;旧格式锁保留且不写配置。
  • 后端确认预发 Console 网关和浏览器回调源后,用真实账户完成跨进程登录、复用、续期和退出验收。
  • 正式环境 OAuth 应用配置确认后,完成线上首次登录验收。

…lation

- add `bl auth --login aliyun` PKCE loopback flow (/oauth/callback), token ->
  STS exchange (PascalCase/camelCase compatible) -> GenerateCLIAccessToken ->
  loginInfo, with three-branch auto renewal
- store OAuth sessions as private plaintext files (0600 + atomic write,
  Windows private ACL) instead of OS keychain, aligned with aliyun-cli
- add BAILIAN_PRE control-plane switch: isolated pre/control-pre.json
  profiles with control_environment guard, verified pre endpoints for
  OAuth/OpenAPI, and hard blocks for unverified management routes
Preserve the upstream CLI exit, request attribution, and AccessKey guide while keeping OAuth and pre-release Console routing isolated.
Recover abandoned locks without rolling back committed credentials, keep route selection aligned with the actual credential, and protect sessions from concurrent logout. Cancel in-flight OAuth requests promptly and show only valid pre-release recovery steps.
Stop retries when their credential binding changes, including while a new token is in flight. Preserve legacy lock files rather than risking removal of a lock owned by an older writer.
Accept pasted callbacks without a local listener and protect interactive input. Keep OAuth diagnostics parseable in JSON mode and preserve help and required-flag behavior for commands with subcommands.
… site support

Replace the beta-only `bl auth --login aliyun` root entry with a fourth
login mode `bl auth login --oauth`, aligned with --console/--open-api.
--console-site selects domestic/international; --console-region only sets
the saved console_region and Console routing while OAuth endpoints follow
the site alone. International pre-release ships the approved client ID
with placeholder endpoints that block live login until confirmed;
international production stays hard-blocked. Session fingerprints now
include the console site, so existing beta sessions re-login once.
… E2E harness

The commands E2E harness (subprocess and in-process) now resolves
BAILIAN_PRE like the product entrypoint; previously pre-release cases
silently ran against the online branch. Adds loginPlan quadrant coverage
(domestic/international x pre/online), region override isolation, cross-site
re-login rejection, profile parse compatibility and refresh-target tests.
… status

Update README copies, the auth-change agent guide and regenerated skill
references for the new OAuth entry, site/region semantics, the confirmed
international pre-release application and the pending endpoint group.
…e endpoints

signin/oauth come from the IMS open docs; console origin/gateway match
inner-console-call pre.singapore. The two OpenAPI hosts stay unconfirmed,
so live international pre-release login remains gated.
…h recovery

Restore workspace init to auth:none with explicit AK flags while keeping
pre-release gateway routing; add tolerateInvalidOAuth recovery reads so a
corrupted aliyun_oauth block no longer bricks logout/re-login/config set;
drop the unverified 30-day console session claim from auth login --oauth.
- Route pre-release OpenAPI hosts by the OAuth profile site so international
  pre no longer resolves to domestic endpoints
- Revoke the previous refresh token best-effort on relogin; logout stays
  local-first and warns instead of blocking when revoke fails offline
- Scale session-lock wait budget with the operation timeout (two serial
  exchanges plus headroom, 30s floor)
- Pre dry-run marks an explicit --console-gateway unverified when the env
  gateway is unset; configured gateways still must match the trusted value
- Redact reflected refresh tokens in revoke failures across raw,
  percent-encoded and form-encoded forms
- Cover the new contracts, lock-wait budget and the 16KB manual-callback
  boundary in tests
@lishengzxc lishengzxc changed the title feat(auth): 接入阿里云 OAuth 登录与预发控制面隔离 feat(auth): 接入阿里云 OAuth 登录与预发控制面隔离 (prepare 2.16.0) Dec 1, 2026
…ional login

Embed the production IAM client IDs and signin/oauth endpoints for both
sites so a first online login needs no endpoint flags; --client-id and
--authorization-url become optional overrides. Drop the international
online usage block (app approved, same client ID as pre-release); the
pre-release endpoint gates stay unchanged. Update unit/e2e contracts,
bilingual READMEs, the auth-change guide and the skill reference.
@hopelynd
hopelynd added this pull request to stack #365 December 2, 2026 03:52

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant